/* matmult.c 
*    Test program to do matrix multiplication on large arrays.
*
*    Intended to stress virtual memory system.
*
*    Ideally, we could read the matrices off of the file system,
*	and store the result back to the file system!
*/

#include "syscall.h"
#include "utils.h"

#define Dim 	20	/* sum total of the arrays doesn't fit in 
* physical memory 
*/

int A[Dim][Dim];
int B[Dim][Dim];
int C[Dim][Dim];

int
	main()
{
	int i, j, k;

	for (i = 0; i < Dim; i++) {		/* first initialize the matrices */
		for (j = 0; j < Dim; j++) {
			A[i][j] = i;
			B[i][j] = j;
			C[i][j] = 0;
		/*	printf("Did something.\n",0,0,0,"","");*/
		}
	}
	printf("Did the initialization.\n", 0,0,0,"","");

	for (i = 0; i < Dim; i++) {	/* then multiply them together */
		printf("Top level %d.\n",i,0,0,"","");
		for (j = 0; j < Dim; j++) {
			for (k = 0; k < Dim; k++)
				C[i][j] += A[i][k] * B[k][j];
		}
	}

	Exit(C[Dim-1][Dim-1]);		/* and then we're done */
}
